import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import './assets/fonts/iconfont.css'
import './assets/css/normalize.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import './plugins/timeline/timeline.css'
import './plugins/timeline-item/timeline-item.css'

Vue.config.productionTip = false
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem('token')
  return config
})
Vue.filter('dateFormat', function(date) {
  const times = new Date(date)
  const y = times.getFullYear()
  let M = times.getMonth() + 1
  M = M > 9 ? M : '0' + M
  let d = times.getDate()
  d = d > 9 ? d : '0' + d
  let h = times.getHours()
  h = h > 9 ? h : '0' + h
  let m = times.getMinutes()
  m = m > 9 ? m : '0' + m
  let s = times.getSeconds()
  s = s > 9 ? s : '0' + s
  return `${y}-${M}-${d} ${h}:${m}:${s}`
})
Vue.use(VueQuillEditor)
Vue.prototype.$http = axios
Vue.component('tree-table', TreeTable)
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
